home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-gobject / examples / option.py next >
Encoding:
Python Source  |  2009-02-17  |  861 b   |  31 lines

  1. #!/usr/bin/env python
  2. # gnome-python/pygobject/examples/option.py
  3.  
  4. from gobject.option import OptionGroup, OptionParser, make_option
  5.  
  6. group = OptionGroup("example", "OptionGroup Example", "Shows all example options",
  7.     option_list = [
  8.         make_option("--example",
  9.                     action="store_true",
  10.                     dest="example",
  11.                     help="An example option."),
  12.     ])
  13.  
  14. parser = OptionParser("NAMES ...",
  15.     description="A simple gobject.option example.",
  16.     option_list = [
  17.         make_option("--file", "-f",
  18.                     type="filename",
  19.                     action="store",
  20.                     dest="file",
  21.                     help="A filename option"),
  22.         # ...
  23.     ])
  24.  
  25. parser.add_option_group(group)
  26.  
  27. parser.parse_args()
  28.  
  29. print "group: example ", group.values.example
  30. print "parser: file", parser.values.file
  31.